package com.heyu.cgsd.ui.fragment

import android.support.v7.widget.LinearLayoutManager
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import com.heyu.cgsd.R
import com.heyu.cgsd.base.BaseFragment
import com.heyu.cgsd.config.CgsdDataSource
import com.heyu.cgsd.ui.adapter.SettingAdapter
import com.heyu.cgsd.util.DisplayUtil
import kotlinx.android.synthetic.main.fragment_setting.*
import kotlinx.android.synthetic.main.title_bar_base.*

class SettingFragment : BaseFragment() {

    var flTopAd: FrameLayout? = null
    var imgMe: ImageView? = null
    private var settingAdapter: SettingAdapter? = null

    override fun initView() {
        tv_title!!.text = "设置"
        img_back!!.visibility = View.GONE
        img_title!!.visibility = View.GONE
        settingAdapter = SettingAdapter()
        val view = LayoutInflater.from(activity).inflate(R.layout.layout_me_header, null)
        settingAdapter!!.addHeaderView(view)
        flTopAd = view.findViewById(R.id.fl_top_ad)
        imgMe = view.findViewById(R.id.img_me)
        val meLp = imgMe!!.layoutParams as FrameLayout.LayoutParams
        meLp.height = (DisplayUtil.getScreenWidth(activity) - DisplayUtil.dip2px(activity, 32f)) / 2
        imgMe!!.requestLayout()
        recyclerView!!.layoutManager = LinearLayoutManager(activity)
        recyclerView!!.adapter = settingAdapter
        settingAdapter!!.setNewData(CgsdDataSource.getSettingList())
    }

    override fun getContentView(): Int? {
        return R.layout.fragment_setting
    }

}